import React, { forwardRef, useImperativeHandle, useRef, useContext } from 'react'
import { Modal } from 'antd'
import './index.scss'
// 注意Modal与Form一起使用，即使设置destroyOnClose，关闭Modal也不会销毁表单数据，需要设置<Form preserve={false}>
const LdDialog = forwardRef((props: any, ref: any) => {
    const { open = true, handleClose, title = '新建' } = props
    const slotArray = React.Children.toArray(props?.children)
    const handCancel = () => {
        handleClose && handleClose()
    }
    return (
        <>
            <div className="ld-modal">
                <Modal maskClosable={false} onCancel={handCancel} destroyOnClose title={title} open={open} footer={null}>
                    {slotArray.map((item: any, index: number) => {
                        return (
                            <div className='ld-modal-context' key={index}>
                                {item}
                            </div>
                        )
                    })}
                </Modal>
            </div>
        </>
    )
})
export default LdDialog